using System;

namespace HiveSenseV1 {
	class Xml {

		string xml;

		public Xml( byte[] rawXml ) {
			var xmlBuild = new System.Text.StringBuilder( rawXml.Length );
			foreach(byte b in rawXml) {
				xmlBuild.Append( (char) b );
			}
			xml = xmlBuild.ToString();
		}

		public string getElement( string elementName ) {

			string startTag = "<" + elementName + ">";
			string endTag = "</" + elementName + ">";

			int start = xml.IndexOf( startTag ) + startTag.Length;
			int end = xml.IndexOf( endTag );

			if(start <= 0 || end <= 0) {
				return "";
			}

			return xml.Substring( start, end - start ).Trim();
		}
	}
}
